package com.taiguan.eis.solution.eiswebservice.configuration;

import com.taiguan.eis.solution.eiswebservice.service.EqpWebService;
import com.taiguan.eis.solution.eiswebservice.serviceimpl.EqpWebServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import javax.xml.ws.Endpoint;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebServiceConfig {



    @Bean("cxfServletRegistration")
    public ServletRegistrationBean dispatcherServlet(){
        return new ServletRegistrationBean(new CXFServlet(),"/service/*");//发布服务名称
    }

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus()
    {
        return  new SpringBus();
    }

    @Bean
    public EqpWebService beanService()
    {
        return  new EqpWebServiceImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint=new EndpointImpl(springBus(), beanService());//绑定要发布的服务
        endpoint.publish("/api"); //显示要发布的名称
        return endpoint;
    }
}
